﻿<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="text" />
	<xsl:template match="/">
		&lt;?xml version="1.0" encoding="utf-8" ?&gt;		
		&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="<xsl:value-of select="Schema/@BusEntityNameSpace" />" namespace="<xsl:value-of select="Schema/@BusEntityNameSpace" />"&gt;		
		&lt;class name="<xsl:value-of select="Schema/@DataEntityNameSpace" />" table="<xsl:value-of select="Schema/@TableName" />" lazy="true" &gt;

		<xsl:for-each select="Schema/Columns[IsIdentity='true']">
		&lt;id name="<xsl:value-of select="ColumnName"/>" column="<xsl:value-of select="ColumnName"/>" type="<xsl:value-of select="HbmType"/>"&gt;
		&lt;generator class="identity" /&gt;
		&lt;/id&gt;
		</xsl:for-each>

		<xsl:for-each select="Schema/Columns[IsIdentity='false']">
			&lt;property name="<xsl:value-of select="ColumnName"/>" type="<xsl:value-of select="HbmType"/>"&gt;
			&lt;column  name="<xsl:value-of select="ColumnName"/>" not-null="<xsl:value-of select="IsNullable"/>"  length="<xsl:value-of select="MaxLength"/>" /&gt;
			&lt;/property&gt;
		</xsl:for-each>
		&lt;/class&gt;
		&lt;/hibernate-mapping&gt;

	</xsl:template>
</xsl:stylesheet>


